package org.example.managementsystem.service;

import org.example.managementsystem.model.Production_Review;
import org.example.managementsystem.repository.Production_ReviewDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Production_ReviewService {
    private final Production_ReviewDao productionReviewDao;

    @Autowired
    public Production_ReviewService(Production_ReviewDao productionReviewDao) {
        this.productionReviewDao = productionReviewDao;
    }

    public Production_Review addProduction_Review(Production_Review productionReview) {
        int id = productionReviewDao.insertProduction_Review(productionReview);
        productionReview.setSubmission_id(id);
        return productionReview;
    }

    public boolean updateProduction_Review(Production_Review productionReview) {
        return productionReviewDao.updateProduction_Review(productionReview) > 0;
    }

    public boolean deleteProduction_Review(int submissionId) {
        return productionReviewDao.deleteProduction_Review(submissionId) > 0;
    }

    public Production_Review getProduction_ReviewById(int submissionId) {
        return productionReviewDao.getProduction_ReviewById(submissionId);
    }

    public List<Production_Review> getAllProduction_Reviews() {
        return productionReviewDao.getAllProduction_Review();
    }
}